package com.api.utils;

import android.Manifest;

import com.tbruyelle.rxpermissions2.RxPermissions;

import io.reactivex.functions.Consumer;
import me.goldze.mvvmhabit.base.BaseActivity;

public class PermissionUtils {

    public static void permission(BaseActivity activity, final PermissionFinish permissionFinish){
        RxPermissions rxPermissions = new RxPermissions(activity);
        rxPermissions.request(Manifest.permission.CAMERA,Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)
                .subscribe(new Consumer<Boolean>() {
                    @Override
                    public void accept(Boolean granted) throws Exception {
                        if (granted){
                            permissionFinish.success();
                        }else {
                            System.exit(0);
                        }
                    }
                });
    }
    public interface PermissionFinish{
        void success();
    }


}
